<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Azure Table Storage Query Analysis</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            margin: 20px;
            max-width: 800px;
        }
        .question {
            background-color: #f9f9f9;
            padding: 15px;
            border-radius: 5px;
            margin-bottom: 20px;
        }
        .code-block {
            background-color: #f0f0f0;
            padding: 10px;
            border-radius: 5px;
            font-family: Consolas, monospace;
            white-space: pre-wrap;
            margin: 10px 0;
        }
        .statement-table {
            width: 100%;
            border-collapse: collapse;
            margin: 20px 0;
        }
        .statement-table th, .statement-table td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }
        .statement-table th {
            background-color: #f2f2f2;
        }
        .radio-group {
            justify-content: center;
            gap: 20px;
        }
        .answer-btn {
            background-color: #4CAF50;
            color: white;
            padding: 10px 15px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            margin-top: 10px;
        }
        .answer-btn:hover {
            background-color: #45a049;
        }
        .answer-section {
            display: none;
            margin-top: 20px;
            padding: 15px;
            background-color: #f9f9f9;
            border-left: 5px solid #4CAF50;
            border-radius: 5px;
        }
        .correct-answer {
            background-color: #e7f7e7;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <h1>Azure Table Storage Query Analysis</h1>
    
    <div class="question">
        <p><strong>QUESTION NO: 147 HOTSPOT</strong></p>
        <p>You have an app that stores player scores for an online game. The app stores data in Azure tables using a class named PlayerScore as the table entity. The table is populated with 100,000 records.</p>
        <p>You are reviewing the following section of code that is intended to retrieve 20 records where the player score exceeds 15,000.</p>
        
        <div class="code-block">
public void GetScore(string playerId, int newScore, string gameName)
{
    TableQuery&lt;PlayerScore&gt; query = new TableQuery&lt;PlayerScore&gt;().Where(
        TableQuery.CombineFilters(
            TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, gameName),
            TableOperators.And,
            TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThanOrEqual, 15000)
        )
    ).Take(20).Select(new TableQuery.SelectColumnsInfo[] { new TableQuery.SelectColumnsInfo("Score") });

    foreach (var item in scoreTable.ExecuteQuery(query, resolv, null, null))
    {
        int scoreItem = (int)item["Score"];
        Console.WriteLine("scoreEntry: {0}", scoreItem.Value);
    }
}

public class PlayerScore : TableEntity
{
    public PlayerScore(string gameId, string playerId, int score, long timePlayed)
    {
        this.PartitionKey = gameId;
        this.RowKey = playerId;
        Score = score;
        TimePlayed = timePlayed;
    }

    public int Score { get; set; }
    public long TimePlayed { get; set; }
}
        </div>
        
        <p>For each of the following statements, select Yes if the statement is true. Otherwise, select No.</p>
        <p><em>NOTE: Each correct selection is worth one point.</em></p>
        
        <table class="statement-table">
            <tr>
                <th>描述</th>
                <th>Yes</th>
                <th>No</th>
            </tr>
            <tr>
                <td>The code queries the Azure table and retrieves the TimePlayed property from the table.</td>
                <td class="radio-group"><input type="radio" name="q1" value="Yes" /></td>
                <td class="radio-group"><input type="radio" name="q1" value="No" /></td>
            </tr>
            <tr>
                <td>The code will display a maximum of twenty records.</td>
                <td class="radio-group"><input type="radio" name="q2" value="Yes"></td>
                <td class="radio-group"><input type="radio" name="q2" value="No"></td>
            </tr>
            <tr>
                <td>All records will be sent to the client. The client will display records for scores greater than or equal to 15,000.</td>
                <td class="radio-group"><input type="radio" name="q3" value="Yes"></td>
                <td class="radio-group"><input type="radio" name="q3" value="No"></td>
            </tr>
            <tr>
                <td>The ScoreEntity.Key property of the KeyValuePair that ExecuteQuery returns will contain a value for PlayerID.</td>
                <td class="radio-group"><input type="radio" name="q4" value="Yes"></td>
                <td class="radio-group"><input type="radio" name="q4" value="No"></td>
            </tr>
        </table>
    </div>

    <button class="answer-btn" onclick="showAnswer()">查看答案</button>

    <div id="answer-section" class="answer-section">
        <h3>答案及说明</h3>
        <table class="statement-table">
            <tr>
                <th>描述</th>
                <th>正确答案</th>
            </tr>
            <tr>
                <td>The code queries the Azure table and retrieves the TimePlayed property from the table.</td>
                <td class="correct-answer">No</td>
            </tr>
            <tr>
                <td>The code will display a maximum of twenty records.</td>
                <td class="correct-answer">Yes</td>
            </tr>
            <tr>
                <td>All records will be sent to the client. The client will display records for scores greater than or equal to 15,000.</td>
                <td class="correct-answer">Yes</td>
            </tr>
            <tr>
                <td>The ScoreEntity.Key property of the KeyValuePair that ExecuteQuery returns will contain a value for PlayerID.</td>
                <td class="correct-answer">Yes</td>
            </tr>
        </table>
        <p><strong>说明:</strong></p>
        <ol>
            <li><strong>TimePlayed property</strong>: 代码中使用了Select方法只选择了"Score"属性，因此不会检索TimePlayed属性。</li>
            <li><strong>Record limit</strong>: 代码中使用了Take(20)方法，会返回最多20条记录。</li>
            <li><strong>Filter condition</strong>: 查询条件是RowKey 是≥15000。</li>
            <li><strong>PlayerID in Key</strong>: PlayerID被用作RowKey，因此会包含在返回的实体键中。</li>
        </ol>
    </div>

    <script>
        function showAnswer() {
            document.getElementById('answer-section').style.display = 'block';
            
            // Set the correct answers in the radio buttons
            document.querySelector('input[name="q1"][value="No"]').checked = true;
            document.querySelector('input[name="q2"][value="Yes"]').checked = true;
            document.querySelector('input[name="q3"][value="Yes"]').checked = true;
            document.querySelector('input[name="q4"][value="Yes"]').checked = true;
        }
    </script>
</body>
</html>
